package net.bolue.sysmng.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.bolue.console.model.BusiBase;
import net.bolue.sysmng.db.DbOpUtil;
import net.bolue.sysmng.exception.BolueException;
import net.bolue.sysmng.tblbean.MdbopRes;
import net.bolue.sysmng.tblbean.MdbopSubRes;
import net.bolue.web.report.RepConstants;

/**
 * 组合维护业务
 * @author Administrator
 *
 */
public class MdbopResModel extends BusiBase{

	public MdbopResModel(){
		super();
	}
	
	public MdbopResModel(HttpServletRequest request){
		super(request);
	}
	
	/**
	 * 获得组合维护资源
	 * @param subSys
	 * @param mdbopId
	 * @return
	 * @throws BolueException
	 */
	public MdbopRes getMdbopRes(String subSys,String mdbopId) throws BolueException{
		Map<String,Object> whereMap = new HashMap<String,Object>();
		whereMap.put("SUBSYS", subSys);
		whereMap.put("MDBOPID", mdbopId);
		DbOpUtil dbOpUtil = new DbOpUtil(RepConstants.SYSMNG_SUBSYS_KEY);
		MdbopRes mdbopRes = dbOpUtil.getOne(MdbopRes.class, "st_mdbopres", null, whereMap);
		return mdbopRes;
	}
	
	/**
	 * 获得组合维护子资源
	 * @param subSys
	 * @param mdbopId
	 * @return
	 * @throws BolueException
	 */
	public List<MdbopSubRes> getMdbopSubRes(String subSys,String mdbopId) throws BolueException{
		Map<String,Object> whereMap = new HashMap<String,Object>();
		whereMap.put("SUBSYS", subSys);
		whereMap.put("MDBOPID", mdbopId);
		DbOpUtil dbOpUtil = new DbOpUtil(RepConstants.SYSMNG_SUBSYS_KEY);
		Map<String, String> orderMap = new HashMap<String, String>();
		orderMap.put("EXECNO", "ASC");
		List<MdbopSubRes> mdbopSubResList = dbOpUtil.query(MdbopSubRes.class, "st_mdbopsubres", null, whereMap, orderMap);
		return mdbopSubResList;
	}
}
